package com.sn.pw.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.sn.pw.service.BiddingService;
import com.sn.pw.result.Result;
import javax.validation.Valid;
import com.sn.pw.vo.req.IdReq;
import com.sn.pw.vo.req.IdsReq;
import java.util.List;
import com.sn.pw.vo.resp.BiddingResp;
import com.sn.pw.vo.createreq.BiddingCreateReq;
import com.sn.pw.vo.updatereq.BiddingUpdateReq;
import com.sn.pw.page.PageReq;
import com.sn.pw.page.PageResp;

/**
 * <p>
 * 竞价表 controller
 * </p>
 *
 * @author mx
 * @since 2023-12-07
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@Api(tags = "竞价表-Api")
@RestController
@RequestMapping("/bidding")
public class BiddingController {
    private final BiddingService service;

    @PostMapping("/create")
    @ApiOperation(value = "新增")
    public Result createOne(@Valid @RequestBody BiddingCreateReq param){
        service.create(param);
        return Result.success("新增成功");
    }

    @PostMapping("/deleteById")
    @ApiOperation(value = "根据id删除数据")
    public Result delete(@Valid @RequestBody IdReq idReq){
        service.delete(idReq.getId());
        return Result.success("删除成功");
    }

    @PostMapping("/deleteByIds")
    @ApiOperation(value = "根据ids删除多条数据")
    public Result deleteByIds(@Valid @RequestBody IdsReq idsReq){
        service.deleteByIds(idsReq.getIds());
        return Result.success("批量删除成功");
    }




    @PostMapping("/update")
    @ApiOperation(value = "修改")
    public Result update(@Valid @RequestBody BiddingUpdateReq param){
        service.update(param);
        return Result.success("修改成功");
    }

    @PostMapping("/getById")
    @ApiOperation(value = "单条查询")
    public Result getById(@Valid @RequestBody IdReq idReq){
        return Result.success(service.findById(idReq.getId()));
    }

    @PostMapping("/getListById")
    @ApiOperation(value = "id列表查询")
    public Result<List<BiddingResp>> findList(@Valid @RequestBody IdsReq idsReq){
        return Result.success(service.findList(idsReq.getIds()));
    }

}